#!/bin/sh

cd ~/workshop/gitee/3place

find . |grep config |sort -g   |sed -e "/\.git\//d"> tmp

# echo "文件头"

echo "% 个人阅读平台@第三同读">index.md

echo "% hbaolong@vip.qq.com">>index.md

echo "" >>index.md

# echo "herder"

commcode header >>index.md

# echo "每日谚语"

printf "<center> [每日谚语](/3place/for/) </center>\n\n" >> index.md

todayfortune >fortune.md

cat fortune.md  >> index.md

echo ""  >> index.md

# echo "0"

echo "## <a href=\"00.html\">0. 四书五经 </a>" >> index.md

echo "">> index.md

grep "^\.\/0" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

# echo "1"

printf "\n\n## 1. 古典杂项\n\n" >>index.md

grep "^\.\/1" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

# echo "2"

printf "\n\n## 2. 诸子百家\n\n" >>index.md

grep "^\.\/2" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 3. 中国文学\n\n" >>index.md

grep "^\.\/3" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 4. 西方历史哲学\n\n" >>index.md

grep "^\.\/4" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 5. 数学\n\n" >>index.md

grep "^\.\/5" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 6. 管理学\n\n" >>index.md

grep "^\.\/6" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 7. 西方诗歌（文学）\n\n" >>index.md

grep "^\.\/7" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 8. 人物传记\n\n" >>index.md

grep "^\.\/8" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## 9. 个人创作\n\n" >>index.md

grep "^\.\/9" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

printf "\n\n## X. 其他\n\n" >>index.md

sed -e  "/^\.\/[1234567890]/d" tmp > tmp.1

for files in `cat tmp.1`

do

	source $files

	printf "[%s](%s) " $bookname $url >> index.md

done

# echo "footer"

commcode footer >> index.md

pandoc -s index.md -o ~/workshop/hbaolong.github.io/index.html

rm -f tmp.1 tmp